module WallaceTree33Bits(
    input   logic [32:0]    sin,
    input   logic [32:0]    cin,
    output  logic [32:0]    cout,
    output  logic           s,
    output  logic           c
);

/* **************************** first stage **************************** */
    logic [11:0] first_s, first_c;
    CSA csa01 ( .in({sin[32:30]}),       .s(first_s[11]), .c(first_c[11]) );
    CSA csa02 ( .in({sin[29:27]}),       .s(first_s[10]), .c(first_c[10]) );
    CSA csa03 ( .in({sin[26:24]}),       .s(first_s[09]), .c(first_c[09]) );
    CSA csa04 ( .in({sin[23:21]}),       .s(first_s[08]), .c(first_c[08]) );
    CSA csa05 ( .in({sin[20:18]}),       .s(first_s[07]), .c(first_c[07]) );
    CSA csa06 ( .in({sin[17:15]}),       .s(first_s[06]), .c(first_c[06]) );
    CSA csa07 ( .in({sin[14:12]}),       .s(first_s[05]), .c(first_c[05]) );
    CSA csa08 ( .in({sin[11:09]}),       .s(first_s[04]), .c(first_c[04]) );
    CSA csa09 ( .in({sin[08:06]}),       .s(first_s[03]), .c(first_c[03]) );
    CSA csa10 ( .in({sin[05:04], 1'b0}), .s(first_s[02]), .c(first_c[02]) );
    CSA csa11 ( .in({sin[03:02], 1'b0}), .s(first_s[01]), .c(first_c[01]) );
    CSA csa12 ( .in({sin[01:00], 1'b0}), .s(first_s[00]), .c(first_c[00]) );
/* **************************** first stage **************************** */


/* **************************** second stage **************************** */
    logic [07:0] second_s, second_c;
    CSA csa13 ( .in({first_s[11:09]}), .s(second_s[07]), .c(second_c[07]) );
    CSA csa14 ( .in({first_s[08:06]}), .s(second_s[06]), .c(second_c[06]) );
    CSA csa15 ( .in({first_s[05:03]}), .s(second_s[05]), .c(second_c[05]) );
    CSA csa16 ( .in({first_s[02:00]}), .s(second_s[04]), .c(second_c[04]) );
    CSA csa17 ( .in({cin[11:09]}),     .s(second_s[03]), .c(second_c[03]) );
    CSA csa18 ( .in({cin[08:06]}),     .s(second_s[02]), .c(second_c[02]) );
    CSA csa19 ( .in({cin[05:03]}),     .s(second_s[01]), .c(second_c[01]) );
    CSA csa20 ( .in({cin[02:00]}),     .s(second_s[00]), .c(second_c[00]) );
/* **************************** second stage **************************** */


/* **************************** third stage **************************** */
    logic [04:0] third_s, third_c;
    CSA csa21 ( .in({second_s[07:05]}),          .s(third_s[04]), .c(third_c[04]) );
    CSA csa22 ( .in({second_s[04:02]}),          .s(third_s[03]), .c(third_c[03]) );
    CSA csa23 ( .in({second_s[01:00], cin[18]}), .s(third_s[02]), .c(third_c[02]) );
    CSA csa24 ( .in({cin[17:15]}),               .s(third_s[01]), .c(third_c[01]) );
    CSA csa25 ( .in({cin[14:12]}),               .s(third_s[00]), .c(third_c[00]) );
/* **************************** third stage **************************** */


/* **************************** fourth stage **************************** */
    logic [02:0] fourth_s, fourth_c;
    CSA csa26 ( .in({third_s[04:02]}),          .s(fourth_s[02]), .c(fourth_c[02]) );
    CSA csa27 ( .in({third_s[01:00], cin[22]}), .s(fourth_s[01]), .c(fourth_c[01]) );
    CSA csa28 ( .in({cin[21:19]}),              .s(fourth_s[00]), .c(fourth_c[00]) );
/* **************************** fourth stage **************************** */


/* **************************** fifth stage **************************** */
    logic [01:0] fifth_s, fifth_c;
    CSA csa29 ( .in({fourth_s[02:00]}), .s(fifth_s[01]), .c(fifth_c[01]) );
    CSA csa30 ( .in({cin[25:23]}),      .s(fifth_s[00]), .c(fifth_c[00]) );
/* **************************** fifth stage **************************** */

/* **************************** sixth stage **************************** */
    logic [01:0] sixth_s, sixth_c;
    CSA csa31 ( .in({fifth_s[01:00], cin[29]}), .s(sixth_s[01]), .c(sixth_c[01]) );
    CSA csa32 ( .in({cin[28:26]}),              .s(sixth_s[00]), .c(sixth_c[00]) );
/* **************************** sixth stage **************************** */

/* **************************** seventh stage **************************** */
    logic        seventh_s, seventh_c;
    CSA csa33 ( .in({sixth_s[01:00], cin[30]}), .s(seventh_s), .c(seventh_c) );
/* **************************** seventh stage **************************** */

/* **************************** eighth stage **************************** */
    logic        eighth_s, eighth_c;
    CSA csa34 ( .in({seventh_s, cin[32:31]}),   .s(eighth_s), .c(eighth_c) );
/* **************************** eighth stage **************************** */

    assign s = eighth_s;
    assign c = eighth_c;
    assign cout = {seventh_c, sixth_c, fifth_c, fourth_c, third_c, second_c, first_c};

endmodule //WallaceTree17Bits
